// nvtempture1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"


//int _tmain(int argc, _TCHAR* argv[])
//{
//    return 0;
//}

#if 1

#include "stdafx.h"
#include "nvapi.h"


int _tmain(int argc, _TCHAR* argv[])
{
	NvAPI_Status ret = NVAPI_OK;
	int i = 0;

	NvDisplayHandle hDisplay_a[NVAPI_MAX_PHYSICAL_GPUS * 2] = { 0 };

	ret = NvAPI_Initialize();

	if (ret != NVAPI_OK) {
		NvAPI_ShortString string;
		NvAPI_GetErrorMessage(ret, string);
		printf("NVAPI NvAPI_Initialize: %s\n", string);
	}

	NvAPI_ShortString ver;

	NvAPI_GetInterfaceVersionString(ver);
	printf("NVAPI Version: %s\n", ver);

///////////////////////////////////////////////////////////////////////////////

	NvU32 cnt;

	NvPhysicalGpuHandle phys;

	ret = NvAPI_EnumPhysicalGPUs(&phys, &cnt);

	if (ret != NVAPI_OK) {
		NvAPI_ShortString string;
		NvAPI_GetErrorMessage(ret, string);
		printf("NVAPI NvAPI_EnumPhysicalGPUs: %s\n", string);
	}

	NvAPI_ShortString name;

	NV_GPU_THERMAL_SETTINGS thermal;

	ret = NvAPI_GPU_GetFullName(phys, name);
	if (ret != NVAPI_OK) {
		NvAPI_ShortString string;
		NvAPI_GetErrorMessage(ret, string);
		printf("NVAPI NvAPI_GPU_GetFullName: %s\n", string);
	}

	printf("Name: %s\n", name);

//////////////////////////////////////////////////////////////////////////////



	thermal.version = NV_GPU_THERMAL_SETTINGS_VER;
	ret = NvAPI_GPU_GetThermalSettings(phys, 0, &thermal);

	if (ret != NVAPI_OK) {
		NvAPI_ShortString string;
		NvAPI_GetErrorMessage(ret, string);
		printf("NVAPI NvAPI_GPU_GetThermalSettings: %s\n", string);
	}

	printf("Temp: %li C\n", thermal.sensor[0].currentTemp);

	return 0;
}

#endif